I think I've implemented the notion of a dynamic Linked List in DXL. I was inspired after using Arrays with huge number of rows but fixed number of columns; but the columns could extend depending on how many items were associated with the KEY of the row; but assigning large column values multiplies the size of the table by iRowMax X iColMax, and I was running out of memory. Again. Line# #107 int iRow_Tally = (int dxloLList->c_LList_Field_Tally) #160 dxloLList->c_LList_Field_Tally = iRow_Tally
llandale - Sun Feb 19 15:27:36 EST 2012 |
Re: LinkList
Hi Louie,
struct LinkedList {}
// Turn the LinkList into a DxlObject
DxlObject fl_LList_DxloOf (LinkedList in_LList) { return (DxlObject(addr_ in_LList)) }
// constructor for DXL Object
LinkedList fLList_Create_ () { DxlObject dx = new(); return ((addr_ dx) LinkedList) }
// struct properties
void set_FieldArray (LinkedList L, Array ar) { (fl_LList_DxloOf L)->"FieldArray" = ar }
Array get_FieldArray (LinkedList L ) { return ((fl_LList_DxloOf L)->"FieldArray") Array }
void set_FieldTally (LinkedList L, int ar) { (fl_LList_DxloOf L)->"FieldTally" = ar }
int get_FieldTally (LinkedList L ) { return ((fl_LList_DxloOf L)->"FieldTally") int }
void set_FieldSkip (LinkedList L, Skip ar) { (fl_LList_DxloOf L)->"FieldSkip" = ar }
Skip get_FieldSkip (LinkedList L ) { return ((fl_LList_DxloOf L)->"FieldSkip") Skip }
void set_sFieldLast (LinkedList L, string ar) { (fl_LList_DxloOf L)->"sFieldLast" = ar }
string get_sFieldLast (LinkedList L ) { return ((fl_LList_DxloOf L)->"sFieldLast") string }
void set_iFieldLast (LinkedList L, int ar) { (fl_LList_DxloOf L)->"iFieldLast" = ar }
int get_iFieldLast (LinkedList L ) { return ((fl_LList_DxloOf L)->"iFieldLast") int }
void fLList_Put(LinkedList in_LList, string in_NameList, in_Item) {
...if (null in_LList or ...) return
// this is for sure a programming error! Make it obvious to the programmer by explicitly raising an error!
if (null arr_List or null skp_Index) return
struct ListContainer {}
// Properties:
// Key: list label (string) Value: Root Item (LinkedList)
// stores the column heads and the root list items
Skip get_RootItems (LinkedList) { ... }
void set_RootItems_(LinkedList, Skip) {... }
// set the root element for list with label 'sLabel'
void setRootItem (LinkedList, string sLabel, ListItem) { ... }
// allows you to write insertItem( MyList["column"], "A")
ListItem ::[] (LinkedList L, string label) { ...}
// how about some syntactic sugar? myLinkedList["A"] <- "New Item"
struct ListItem {}
Properties:
ListItem get_nextItem(ListItem)
string get_Value(ListItem)
Methods:
// inserts the element sItem in the list starting at listStart
insertItem (ListItem listStart, string sItem)
// Allocate initial memory for 10000 list items
// one row is one ListItem, columns store the properties
Array garListItemMemory = create(10000, 3 )
// stores the next row in the list memory array to be allocated
int giListItemHandleCount = 0
// This skip stores the rows that have been invalidated, i.e. deleted and can be reused
Skip skFreeListItemNodes = create()
int giFreeListItemNodes = 0
struct ListItem {}
// ... Properties ...
ListItem getNext (ListItem x) { return (get(garListItemMemory, (addr_ x) int, 0)) ListItem }
void setNext_ (ListItem x, ListItem val ) { put(garListItemMemory, val, (addr_ x) int, 0) }
string getValue (ListItem x) { return (get(garListItemMemory, (addr_ x) int, 1)) ListItem }
void setValue (ListItem x, ListItem val ) { put(garListItemMemory, val, (addr_ x) int, 1) }
// constructor & destructor for List
ListItem createListItem_ () {
ListItem x = null
// reuse an existing list nodem if possible
if (giFreeListItemNodes > 0) {
// print "Reallocating Stack Nr " giFreeListItemNodes "\n"
if (!find(skFreeListItemNodes, giFreeListItemNodes--, x)) error "ListItem memory error!"
} else {
// allocate a new row: Note that a ListItem now is only a single number!
x = (addr_ (++giListItemHandleCount) ) ListItem;
}
// print "Allocated ListItem node " ((addr_ x) int) "\n"
return x
}
void deleteListItem (ListItem &t) {
// put in free list nodes
ListItem deref = t
put (skFreeListItemNodes, ++giFreeListItemNodes, deref, true)
// print "Freeing ListItem Slot: " (listItemHandle t)" in Stack Nr: " (giFreeListItemNodes-1) "\n"
// Set all properties to zero here, so your array will be nice and clean!
setValue (t, "")
setNext_ (t, null ListItem
t = null
}
// ... implement append, delete, etc. ....
ListItem I = myLinkedList["A"]
while (!null getNext I) { print "Value:" (getValue I) "\n"; I = getNext I }
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
Re: LinkList Mathias Mamsch - Mon Feb 20 07:21:53 EST 2012
Hi Louie,
struct LinkedList {}
// Turn the LinkList into a DxlObject
DxlObject fl_LList_DxloOf (LinkedList in_LList) { return (DxlObject(addr_ in_LList)) }
// constructor for DXL Object
LinkedList fLList_Create_ () { DxlObject dx = new(); return ((addr_ dx) LinkedList) }
// struct properties
void set_FieldArray (LinkedList L, Array ar) { (fl_LList_DxloOf L)->"FieldArray" = ar }
Array get_FieldArray (LinkedList L ) { return ((fl_LList_DxloOf L)->"FieldArray") Array }
void set_FieldTally (LinkedList L, int ar) { (fl_LList_DxloOf L)->"FieldTally" = ar }
int get_FieldTally (LinkedList L ) { return ((fl_LList_DxloOf L)->"FieldTally") int }
void set_FieldSkip (LinkedList L, Skip ar) { (fl_LList_DxloOf L)->"FieldSkip" = ar }
Skip get_FieldSkip (LinkedList L ) { return ((fl_LList_DxloOf L)->"FieldSkip") Skip }
void set_sFieldLast (LinkedList L, string ar) { (fl_LList_DxloOf L)->"sFieldLast" = ar }
string get_sFieldLast (LinkedList L ) { return ((fl_LList_DxloOf L)->"sFieldLast") string }
void set_iFieldLast (LinkedList L, int ar) { (fl_LList_DxloOf L)->"iFieldLast" = ar }
int get_iFieldLast (LinkedList L ) { return ((fl_LList_DxloOf L)->"iFieldLast") int }
void fLList_Put(LinkedList in_LList, string in_NameList, in_Item) {
...if (null in_LList or ...) return
// this is for sure a programming error! Make it obvious to the programmer by explicitly raising an error!
if (null arr_List or null skp_Index) return
struct ListContainer {}
// Properties:
// Key: list label (string) Value: Root Item (LinkedList)
// stores the column heads and the root list items
Skip get_RootItems (LinkedList) { ... }
void set_RootItems_(LinkedList, Skip) {... }
// set the root element for list with label 'sLabel'
void setRootItem (LinkedList, string sLabel, ListItem) { ... }
// allows you to write insertItem( MyList["column"], "A")
ListItem ::[] (LinkedList L, string label) { ...}
// how about some syntactic sugar? myLinkedList["A"] <- "New Item"
struct ListItem {}
Properties:
ListItem get_nextItem(ListItem)
string get_Value(ListItem)
Methods:
// inserts the element sItem in the list starting at listStart
insertItem (ListItem listStart, string sItem)
// Allocate initial memory for 10000 list items
// one row is one ListItem, columns store the properties
Array garListItemMemory = create(10000, 3 )
// stores the next row in the list memory array to be allocated
int giListItemHandleCount = 0
// This skip stores the rows that have been invalidated, i.e. deleted and can be reused
Skip skFreeListItemNodes = create()
int giFreeListItemNodes = 0
struct ListItem {}
// ... Properties ...
ListItem getNext (ListItem x) { return (get(garListItemMemory, (addr_ x) int, 0)) ListItem }
void setNext_ (ListItem x, ListItem val ) { put(garListItemMemory, val, (addr_ x) int, 0) }
string getValue (ListItem x) { return (get(garListItemMemory, (addr_ x) int, 1)) ListItem }
void setValue (ListItem x, ListItem val ) { put(garListItemMemory, val, (addr_ x) int, 1) }
// constructor & destructor for List
ListItem createListItem_ () {
ListItem x = null
// reuse an existing list nodem if possible
if (giFreeListItemNodes > 0) {
// print "Reallocating Stack Nr " giFreeListItemNodes "\n"
if (!find(skFreeListItemNodes, giFreeListItemNodes--, x)) error "ListItem memory error!"
} else {
// allocate a new row: Note that a ListItem now is only a single number!
x = (addr_ (++giListItemHandleCount) ) ListItem;
}
// print "Allocated ListItem node " ((addr_ x) int) "\n"
return x
}
void deleteListItem (ListItem &t) {
// put in free list nodes
ListItem deref = t
put (skFreeListItemNodes, ++giFreeListItemNodes, deref, true)
// print "Freeing ListItem Slot: " (listItemHandle t)" in Stack Nr: " (giFreeListItemNodes-1) "\n"
// Set all properties to zero here, so your array will be nice and clean!
setValue (t, "")
setNext_ (t, null ListItem
t = null
}
// ... implement append, delete, etc. ....
ListItem I = myLinkedList["A"]
while (!null getNext I) { print "Value:" (getValue I) "\n"; I = getNext I }
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
Anyway, the underlying "Array" inside a "DxlObject" equated to some new "struct" is suitable for this task? PreambleMy immediate task is this: given an interface from equipment eS (source) to equipment eD (destination) that may be along circuit cI, I want to associate cI both eS and eD. Both eS and eD are involved in other interfaces along other circuits. After parsing all the interfaces, I want to get the list of all circuits associated with each equipment. I see 50,000 pieces of equipment making the natural Skip List for each equipment approach unmanageable. Having an Array with 50,000 rows and X columns; where "X" is the most circuits associated with any equipment (45); a 50,000 X 45 Array is exceeding memory.So I figured I needed user functions that use memory linearly:
So I believe I need one container for each kind of relationship; in the above case there would be two: "Equipment Circuits" and "Equipment Documents". The code fails to mention that and I guess therefor you missed that. Responses
I will say I care a great deal about "understandability". The user-interface to this suite needs to be "simple" and "elegant"; and the entire suite needs to be "understandable", not just the topmost get and put functions. I think I'll climb down the ladder into the deep end. -Louie Note: "Back in school" of course means before there were actual computers, just theoretical ones. A "monitor" was the dude with the notepad wandering the halls. "Download" was done with the bathroom door shut. A "bug" was a cockroach (really, stuck on the wiring shorting out the circuits). |
Re: LinkList llandale - Mon Feb 20 12:52:15 EST 2012 PreambleMy immediate task is this: given an interface from equipment eS (source) to equipment eD (destination) that may be along circuit cI, I want to associate cI both eS and eD. Both eS and eD are involved in other interfaces along other circuits. After parsing all the interfaces, I want to get the list of all circuits associated with each equipment. I see 50,000 pieces of equipment making the natural Skip List for each equipment approach unmanageable. Having an Array with 50,000 rows and X columns; where "X" is the most circuits associated with any equipment (45); a 50,000 X 45 Array is exceeding memory.So I figured I needed user functions that use memory linearly:
So I believe I need one container for each kind of relationship; in the above case there would be two: "Equipment Circuits" and "Equipment Documents". The code fails to mention that and I guess therefor you missed that. Responses
I will say I care a great deal about "understandability". The user-interface to this suite needs to be "simple" and "elegant"; and the entire suite needs to be "understandable", not just the topmost get and put functions. I think I'll climb down the ladder into the deep end. -Louie Note: "Back in school" of course means before there were actual computers, just theoretical ones. A "monitor" was the dude with the notepad wandering the halls. "Download" was done with the bathroom door shut. A "bug" was a cockroach (really, stuck on the wiring shorting out the circuits).
Hmm... I am not sure if I was helpful, or destructive. The former one was my intention ... Well nevertheless I will try to explain.
void func(Skip &ref) {
if (null ref) print "Null Skip was passed!"
}
Skip sk = null; func (sk)
void delete (Skip &ref) {
Skip sk = ref // dereference
if (null sk) return
delete sk
ref = null
}
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
Attachments attachment_14791938_LinkedList_Refactored.dxl |
Re: LinkList Mathias Mamsch - Mon Feb 20 16:32:48 EST 2012
Hmm... I am not sure if I was helpful, or destructive. The former one was my intention ... Well nevertheless I will try to explain.
void func(Skip &ref) {
if (null ref) print "Null Skip was passed!"
}
Skip sk = null; func (sk)
void delete (Skip &ref) {
Skip sk = ref // dereference
if (null sk) return
delete sk
ref = null
}
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
Dang, had already re-written it. I can see your brilliance here on the Horizon, but I'm not ready for that yet; psycologically I'm still "inside the box".
} // end for every student
of perhaps also:
Making the code rather "elegant":
for NameStudent in LSet_Teachers do
{ for NameTeacher in current(LSet_Teachers) do
{ Report Student-Teacher relationship
}
}
|
Re: LinkList Mathias Mamsch - Mon Feb 20 16:32:48 EST 2012
Hmm... I am not sure if I was helpful, or destructive. The former one was my intention ... Well nevertheless I will try to explain.
void func(Skip &ref) {
if (null ref) print "Null Skip was passed!"
}
Skip sk = null; func (sk)
void delete (Skip &ref) {
Skip sk = ref // dereference
if (null sk) return
delete sk
ref = null
}
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
As far as noticing that reference thing...
bool isNull(Skip skp) { return(null skp) }
void deleteSkip (Skip &ref) {
if (isNull ref) {print "cannot delete a null Skip\n"; return}
delete ref
ref = null
}
Skip sk = null; deleteSkip (sk)
print "Done. now null: " (null sk) "\t" (isNull sk) "\n"
sk = create(); deleteSkip (sk)
print "Done. now null: " (null sk) "\t" (isNull sk) "\n"
|
Re: LinkList llandale - Tue Feb 21 11:35:33 EST 2012
As far as noticing that reference thing...
bool isNull(Skip skp) { return(null skp) }
void deleteSkip (Skip &ref) {
if (isNull ref) {print "cannot delete a null Skip\n"; return}
delete ref
ref = null
}
Skip sk = null; deleteSkip (sk)
print "Done. now null: " (null sk) "\t" (isNull sk) "\n"
sk = create(); deleteSkip (sk)
print "Done. now null: " (null sk) "\t" (isNull sk) "\n"
|
Re: LinkList llandale - Tue Feb 21 11:35:33 EST 2012
As far as noticing that reference thing...
bool isNull(Skip skp) { return(null skp) }
void deleteSkip (Skip &ref) {
if (isNull ref) {print "cannot delete a null Skip\n"; return}
delete ref
ref = null
}
Skip sk = null; deleteSkip (sk)
print "Done. now null: " (null sk) "\t" (isNull sk) "\n"
sk = create(); deleteSkip (sk)
print "Done. now null: " (null sk) "\t" (isNull sk) "\n"
Funny thing. This seems to work, although I really cannot tell why on the first glance. It seems the DXL interpreter will dereference automatically here, before calling null. Seems to have problems casting from _y& to _n ;-)
// I am sure I have seen references to underscore types work!
// The DXL interpeter seems to do its magic dereferencing before passing to 'null'.
bool isNull (_y &ref) { return null ref }
bool func(Skip &ref) { return isNull ref }
bool func2(Skip sk) { return isNull sk }
Skip sk = null
print "Null: " (isNull sk) "\n"
print "Null: " (func sk) "\n"
print "Null: " (func2 sk) "\n"
sk = create()
print "Not Null: " (isNull sk) "\n"
print "Not Null: " (func sk) "\n"
print "Not Null: " (func2 sk) "\n"
delete sk
Skip n () { return null Skip }
// print (isNull (null Skip)) // this is not possible! DXL interpreter jumps in here!
// print (isNull ( n() )) // this neither! DXL interpreter jumps in here!
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
Re: LinkList Mathias Mamsch - Wed Feb 22 11:08:28 EST 2012
Funny thing. This seems to work, although I really cannot tell why on the first glance. It seems the DXL interpreter will dereference automatically here, before calling null. Seems to have problems casting from _y& to _n ;-)
// I am sure I have seen references to underscore types work!
// The DXL interpeter seems to do its magic dereferencing before passing to 'null'.
bool isNull (_y &ref) { return null ref }
bool func(Skip &ref) { return isNull ref }
bool func2(Skip sk) { return isNull sk }
Skip sk = null
print "Null: " (isNull sk) "\n"
print "Null: " (func sk) "\n"
print "Null: " (func2 sk) "\n"
sk = create()
print "Not Null: " (isNull sk) "\n"
print "Not Null: " (func sk) "\n"
print "Not Null: " (func2 sk) "\n"
delete sk
Skip n () { return null Skip }
// print (isNull (null Skip)) // this is not possible! DXL interpreter jumps in here!
// print (isNull ( n() )) // this neither! DXL interpreter jumps in here!
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
As for the body of your example.
I get this incorrect output:
[2] When I replace the isNull function to be specifically for Skips
I get this incorrect output:
So neither your "_y" generic nor my "Skip" specific isNull works.
I get this correct output:
int Get(int i){return i++}
void Set(int &i) {i++}
int j = 0
Set(j) // OK; Set() can change the value of a variable
Set(10) // Interpret Errors; Set() cannot modify a constant
Set(Get(j)) // Interpret Errors; Set() cannot modify the output of some function
|
Re: LinkList llandale - Wed Feb 22 13:41:27 EST 2012
As for the body of your example.
I get this incorrect output:
[2] When I replace the isNull function to be specifically for Skips
I get this incorrect output:
So neither your "_y" generic nor my "Skip" specific isNull works.
I get this correct output:
int Get(int i){return i++}
void Set(int &i) {i++}
int j = 0
Set(j) // OK; Set() can change the value of a variable
Set(10) // Interpret Errors; Set() cannot modify a constant
Set(Get(j)) // Interpret Errors; Set() cannot modify the output of some function
LoL. Okay that explains it. I misread the output, it did NOT work. So as I intended to write in the first place you need the following function:
// dereference the reference before null checking ...
bool isNull (_y &ref) {
int &a = addr_ ref; // cast to int, otherwise the DXL interpeter goes berserk
int b = a; // dereference
return null b // now do the null check
}
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
Re: LinkList Mathias Mamsch - Wed Feb 22 14:25:59 EST 2012
LoL. Okay that explains it. I misread the output, it did NOT work. So as I intended to write in the first place you need the following function:
// dereference the reference before null checking ...
bool isNull (_y &ref) {
int &a = addr_ ref; // cast to int, otherwise the DXL interpeter goes berserk
int b = a; // dereference
return null b // now do the null check
}
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
Seems to work for "int", "char", "Object", and "Array", but not for "string"
bool isNull (_y &ref) {
int &a = addr_ ref; // cast to int, otherwise the DXL interpeter goes berserk
int b = a; // dereference
return null b // now do the null check
}
bool isNullRef(string &s) {return isNull s}
bool IsNullVal(string s) {return isNull s}
string s
s = " "; print "Null s=space\t" (isNull s) "\t" (isNullRef s)"\t" (IsNullVal s) "\n"
s = ""; print "Null s=\"\"\t" (isNull s) "\t" (isNullRef s)"\t" (IsNullVal s) "\n"
s = null; print "Null s=null\t" (isNull s) "\t" (isNullRef s)"\t" (IsNullVal s) "\n"
-Louie
|
Re: LinkList llandale - Wed Feb 22 15:29:26 EST 2012 Seems to work for "int", "char", "Object", and "Array", but not for "string"
bool isNull (_y &ref) {
int &a = addr_ ref; // cast to int, otherwise the DXL interpeter goes berserk
int b = a; // dereference
return null b // now do the null check
}
bool isNullRef(string &s) {return isNull s}
bool IsNullVal(string s) {return isNull s}
string s
s = " "; print "Null s=space\t" (isNull s) "\t" (isNullRef s)"\t" (IsNullVal s) "\n"
s = ""; print "Null s=\"\"\t" (isNull s) "\t" (isNullRef s)"\t" (IsNullVal s) "\n"
s = null; print "Null s=null\t" (isNull s) "\t" (isNullRef s)"\t" (IsNullVal s) "\n"
-Louie
Ok, we are getting closer. Of course we need additional ones for real and string (as the perms list has), since they do not have a 0 null value, but a null constant (empty string / 0.0 real value):
bool isNull (_y &ref) {
int &a = addr_ ref; // cast to int, otherwise the DXL interpeter goes berserk
int b = a; // dereference
return null b // now do the null check
}
bool isNull (string &ref) {
string b = ref; // dereference
return null b // now do the null check
}
bool isNull (real &ref) {
real b = ref; // dereference
return null b // now do the null check
}
bool func(Skip &ref) { return isNull ref }
bool func2(Skip sk) { return isNull sk }
Skip sk = null
print "Null: " (isNull sk) "\n"
print "Null: " (func sk) "\n"
print "Null: " (func2 sk) "\n"
sk = create()
print "Created: " (isNull sk) "\n"
print "Created: " (func sk) "\n"
print "Created: " (func2 sk) "\n"
delete sk
{
string s = null;
print "NullString: " (isNull s) "\n"
s = "Hallo"
print "Created String: " (isNull s) "\n"
}
{
real s = null;
print "Null Real: " (isNull s) "\n"
s = 1.0
print "Created Real: " (isNull s) "\n"
}
Skip n () { return null Skip }
// print (isNull (null Skip)) // this is not possible! DXL interpreter jumps in here!
// print (isNull ( n() )) // this neither! DXL interpreter jumps in here!
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
Re: LinkList Mathias Mamsch - Wed Feb 22 15:48:21 EST 2012 Ok, we are getting closer. Of course we need additional ones for real and string (as the perms list has), since they do not have a 0 null value, but a null constant (empty string / 0.0 real value):
bool isNull (_y &ref) {
int &a = addr_ ref; // cast to int, otherwise the DXL interpeter goes berserk
int b = a; // dereference
return null b // now do the null check
}
bool isNull (string &ref) {
string b = ref; // dereference
return null b // now do the null check
}
bool isNull (real &ref) {
real b = ref; // dereference
return null b // now do the null check
}
bool func(Skip &ref) { return isNull ref }
bool func2(Skip sk) { return isNull sk }
Skip sk = null
print "Null: " (isNull sk) "\n"
print "Null: " (func sk) "\n"
print "Null: " (func2 sk) "\n"
sk = create()
print "Created: " (isNull sk) "\n"
print "Created: " (func sk) "\n"
print "Created: " (func2 sk) "\n"
delete sk
{
string s = null;
print "NullString: " (isNull s) "\n"
s = "Hallo"
print "Created String: " (isNull s) "\n"
}
{
real s = null;
print "Null Real: " (isNull s) "\n"
s = 1.0
print "Created Real: " (isNull s) "\n"
}
Skip n () { return null Skip }
// print (isNull (null Skip)) // this is not possible! DXL interpreter jumps in here!
// print (isNull ( n() )) // this neither! DXL interpreter jumps in here!
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
I got the generic one to break.
bool isNull (_y &ref) {
int &a = addr_ ref; // cast to int, otherwise the DXL interpeter goes berserk
int b = a; // dereference
return null b // now do the null check
}
struct CL {}
CL create() {int d = 1; CL cl = (CL addr_ d); return(cl)}
CL cl1 = null,
cl2 = create(),
cl3 // <<-- remains undefined
print "cl1\t" (isNull(cl1)) "\n" // true OK
print "cl2\t" (isNull(cl2)) "\n" // false OK
print "cl3\t" (isNull(cl3)) "\n" // <Line:3> unassigned variable (a) <int b = a>
|
Re: LinkList llandale - Thu Feb 23 13:25:14 EST 2012 I got the generic one to break.
bool isNull (_y &ref) {
int &a = addr_ ref; // cast to int, otherwise the DXL interpeter goes berserk
int b = a; // dereference
return null b // now do the null check
}
struct CL {}
CL create() {int d = 1; CL cl = (CL addr_ d); return(cl)}
CL cl1 = null,
cl2 = create(),
cl3 // <<-- remains undefined
print "cl1\t" (isNull(cl1)) "\n" // true OK
print "cl2\t" (isNull(cl2)) "\n" // false OK
print "cl3\t" (isNull(cl3)) "\n" // <Line:3> unassigned variable (a) <int b = a>
Well I guess an unassigned variable would cause every function to break, that you pass that variable to? The question is would you want an not assigned variable to be reported as 'isNull'? I guess this would be doable:
bool isNull (_y &ref) {
int &a = addr_ ref; // cast to int, otherwise the DXL interpeter goes berserk
int *ptr = &a;
if (*ptr == -2023406815) return true // really?
int b = a; // dereference
return null b // now do the null check
}
int c
print (isNull c)
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
Re: LinkList Mathias Mamsch - Fri Feb 24 07:21:47 EST 2012
Well I guess an unassigned variable would cause every function to break, that you pass that variable to? The question is would you want an not assigned variable to be reported as 'isNull'? I guess this would be doable:
bool isNull (_y &ref) {
int &a = addr_ ref; // cast to int, otherwise the DXL interpeter goes berserk
int *ptr = &a;
if (*ptr == -2023406815) return true // really?
int b = a; // dereference
return null b // now do the null check
}
int c
print (isNull c)
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
Since an unassigned check is unreasonable, then your previous 3 functions cover everything, is that right?
bool isNull (_y &ref) {
int &a = addr_ ref; // cast to int, otherwise the DXL interpeter goes berserk
int b = a; // dereference
return null b // now do the null check
}
bool isNull (string &ref) {
string b = ref; // dereference
return null b // now do the null check
}
bool isNull (real &ref) {
real b = ref; // dereference
return null b // now do the null check
}
|